﻿using MainOperation;
namespace LinearRegression
{
    internal class Program
    {
        static void Main(string[] args)
        {
            //从数据文件读取数据
            var model = new GetData();
            model.X= MyFunction.ListReadTxt(@$"E:\vstempt\csharp\LinearRegression\DataFiles\Years.txt");
            model.Y = MyFunction.ListReadTxt(@$"E:\vstempt\csharp\LinearRegression\DataFiles\GDPs.txt");
            //计算参数
            model.Compute();
            //预测
            var gdp = model.Forecast(2022);
            Console.WriteLine($"预测2021年的GDP为{gdp.ToString("##.##")}万亿美元");
            double deviation = (17.73 - gdp) / 17.73 * 100;
            Console.WriteLine($"误差为{deviation.ToString("##.##")}%");
        }
    }
}